'use strict';

/**
 * @param app - egg application
 */
module.exports = app => {

  app.get('/api/v1/card/:id', app.controller.card.show);

  /**
   * 参数：favorite  用户id
   *      openid 查看的名片的用户openid
   **/
  app.post('/api/v1/card/favorite', app.controller.card.favorite);
  /**
   * 参数：check  用户id
   *      openid 查看的名片的用户openid
   **/
  app.post('/api/v1/card/check', app.controller.card.check);
  /**
   * 参数：like  用户id
   *      openid 查看的名片的用户openid
   **/
  app.post('/api/v1/card/like', app.controller.card.like);

  /**
   * 参数：thirdSession, encryptedData, iv
   * 返回：{
        "errMessage": null,
        "errCode": null,
        "data": {
            "openId": "ocs6k5MlJwpstZv_vUdK8NqMXEks",
            "nickName": "趟真",
            "gender": 1,
            "language": "zh_CN",
            "city": "Guangzhou",
            "province": "Guangdong",
            "country": "China",
            "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKeQj8NaUBPGnicMwgHEJbtYXwkkEnWRndDwNSia2lKB5QYWNHnpm388zQawiaW5dN61S9SgicZzVXoqQ/0",
            "watermark": {
                "timestamp": 1519380642,
                "appid": "wx97807883a836a66d"
            }
        }
      }
   **/
  app.post('/api/v1/user/decode', app.controller.wechat.decode);

  /**
   *  参数：code
   *  返回：{
      "errMessage": null,
      "errCode": null,
      "data": {
          "thirdSession": "909619c0187011e8a219159fc0e68637"
      }
    }
   **/
  app.post('/api/v1/getSessionKey', app.controller.wechat.getSessionKey);

  /** 默认接口 **/
  app.resources('card', '/api/v1/card', app.controller.baseController);
};
